from functools import lru_cache

# 使用懒加载装饰器
@lru_cache(maxsize=None)
def get_llmpaper_functions():
    """懒加载 llmpaper 模块的函数"""
    from .papersearch_agent.llmpaper import (
        intent_recognition,
        rank_and_filter,
        generate_report,
        generate_search_keywords,
        execute_search,
        cal_embedding
    )
    return {
        'intent_recognition': intent_recognition,
        'rank_and_filter': rank_and_filter,
        'generate_report': generate_report,
        'generate_search_keywords': generate_search_keywords,
        'execute_search': execute_search,
        'cal_embedding': cal_embedding
    }

# 定义获取函数的方法
def intent_recognition(*args, **kwargs):
    return get_llmpaper_functions()['intent_recognition'](*args, **kwargs)

def rank_and_filter(*args, **kwargs):
    return get_llmpaper_functions()['rank_and_filter'](*args, **kwargs)

def generate_report(*args, **kwargs):
    return get_llmpaper_functions()['generate_report'](*args, **kwargs)

def generate_search_keywords(*args, **kwargs):
    return get_llmpaper_functions()['generate_search_keywords'](*args, **kwargs)

def execute_search(*args, **kwargs):
    return get_llmpaper_functions()['execute_search'](*args, **kwargs)

def cal_embedding(*args, **kwargs):
    return get_llmpaper_functions()['cal_embedding'](*args, **kwargs)

# problem_enhancements 可以保持原样直接导入，因为它是必需的
from .Problem_enhancements.Problem_enhancements import problem_enhancements

__all__ = [
    'problem_enhancements',
    'intent_recognition',
    'rank_and_filter',
    'generate_report',
    'generate_search_keywords',
    'execute_search',
    'cal_embedding'
]